package com.yuzhihao.writejvm.code.f;

import com.yuzhihao.writejvm.code.Operation;
import com.yuzhihao.writejvm.code.StackFrame;
import com.yuzhihao.writejvm.format.FormsEnum;
import com.yuzhihao.writejvm.format.PrintFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * fconst_0
 * @author yzh
 * @see <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.fconst_n">jvmdoc</a>
 * @since 2021年12月16日15:32:03
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class Fconst0 extends Operation {

    private FormsEnum fe = FormsEnum.fconst_0;

    private float value = 0.0f;

    @Override
    public StackFrame exec(StackFrame frame) {

        return frame;
    }

    

    @Override
    public String print(String print) {
        StringBuilder builder = new StringBuilder();
        builder.append(print).append(PrintFormat.EMPTY)
                .append(super.index).append(PrintFormat.COLON)
                .append(PrintFormat.EMPTY).append(fe.name());
        while (builder.length() < PrintFormat.EMPTY_20){
            builder.append(PrintFormat.EMPTY);
        }
        builder.append(this.value);

        return builder.toString();
    }

}
